// pages/codeDetail/codeDetail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    detailList: [{
        tempType: 'title',
        value: '中安大会堂'
      },
      {
        tempType: 'swiper',
        value: [{
          "size": 14849690,
          "duration": 13.334,
          "width": 512,
          "height": 512,
          "type": "video",
          "url": "http://tmp/W1jpT5grN6lhaa638caab161ec721ed7dfa26d89b5d3.mp4",
          "thumb": "http://tmp/AOlqNn52ctDf4c395a1a890f4c62f6d2d3d4cc0882e9.jpg"
        }, {
          "tempFilePath": "http://tmp/cDEiUWcNAtLJ82985e40281751912e762e280b2b3438.png",
          "size": 2315,
          "fileType": "image",
          "type": "image",
          "url": "http://tmp/cDEiUWcNAtLJ82985e40281751912e762e280b2b3438.png",
          "thumb": "http://tmp/cDEiUWcNAtLJ82985e40281751912e762e280b2b3438.png"
        }]
      },
      {
        tempType: 'table',
        value: [{
          name: '参数1',
          value: '值1',
          isUpload: true
        }, {
          name: '参数2',
          value: '值2',
          isUpload: false
        }]
      },
      {
        tempType: "operate",
        type: "list", //list , flow
        value: [{
          aboutForm: {
            id: '', //formId
            jsonList: "",
          },
          // aboutUrl: {
          //   //自定义
          //   type: "signCode", //signCode,web,mini
          //   signId: "",//标识码id获取
          //   url: "https://www.baidu.com",//网页
          //   AppId: "",
          //   originId: "",
          //   path: ""
          // },
          auth: [],
          name: "操作名称",

          //以下为list属性
          nameDetail: "操作详情",
          btnName: "按钮名称",
          btnColor: "#ff000099",

          //以下为flow属性
          icon: ""
        }]
      },
      {
        tempType: "operate",
        type: "flow", //list , flow
        value: [{
            // aboutForm: {
            //   id: '',//formId
            //   jsonList: "",
            // },
            aboutUrl: {
              //自定义
              type: "signCode", //signCode,web,mini
              signId: "", //标识码id获取
              url: "https://www.baidu.com", //网页
              AppId: "",
              originId: "",
              path: ""
            },
            auth: [],
            name: "操作名称",

            //以下为list属性
            nameDetail: "操作详情",
            btnName: "按钮名称",
            btnColor: "#ff000099",

            //以下为flow属性
            icon: "https://img.yzcdn.cn/vant/cat.jpeg"
          },
          {
            // aboutForm: {
            //   id: '',//formId
            //   jsonList: "",
            // },
            aboutUrl: {
              //自定义
              type: "web", //signCode,web,mini
              signId: "", //标识码id获取
              url: "https://www.baidu.com", //网页
              AppId: "",
              originId: "",
              path: ""
            },
            auth: [],
            name: "操作名称",

            //以下为list属性
            nameDetail: "操作详情",
            btnName: "按钮名称",
            btnColor: "#ff000099",

            //以下为flow属性
            icon: "https://img.yzcdn.cn/vant/cat.jpeg"
          },
          {
            // aboutForm: {
            //   id: '',//formId
            //   jsonList: "",
            // },
            aboutUrl: {
              //自定义
              type: "mini", //signCode,web,mini
              signId: "", //标识码id获取
              url: "https://www.baidu.com", //网页
              AppId: "",
              originId: "",
              path: ""
            },
            auth: [],
            name: "操作名称",

            //以下为list属性
            nameDetail: "操作详情",
            btnName: "按钮名称",
            btnColor: "#ff000099",

            //以下为flow属性
            icon: "https://img.yzcdn.cn/vant/cat.jpeg"
          },
        ]
      },
      {
        tempType: "highText",
        value: "<div>hello</div><img src='https://img.yzcdn.cn/vant/cat.jpeg'/>"
      },
      {
        tempType: "map",
        type:"word",//map  word
        value: "[104.04311,30.64242]",
        chineseName:"金融城双子大厦",
        markers: [{
          id: 4,
          latitude: 30.64242,
          longitude: 104.04311,
          width:20,
          height:30,
          customCallout: {
            anchorY: 0,
            anchorX: 20,
            display: 'ALWAYS',
          },
        }]
      },
      {
        tempType: "attachment",
        value: ""
      }
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  goAttachmentDetail(){
    //pdf跳转预览
    wx.navigateTo({
      url: '/pages/attachment/attachment',
    })
  },

  goDeal(e) {
    let itemInfo = e.currentTarget.dataset.params
    //执行表单逻辑
    if (itemInfo?.aboutForm) {
      wx.navigateTo({
        url: '/pages/index/index',
      })
    }
    //执行url跳转逻辑
    if (itemInfo?.aboutUrl) {
      switch (itemInfo?.aboutUrl.type) {
        case 'signCode': {
          wx.navigateTo({
            url: '/pages/codeDetail/codeDetail',
          })
          break
        }
        case 'web': {
          //前提：1.开发者平台配置对应的域名 2.配置后下载证书仍在对方网站的根目录下
          const url = itemInfo?.aboutUrl.url
          wx.navigateTo({
            url: url,
          })
          // console.log(777,url);
          break
        }
        case 'mini': {
          // AppId: "",
          // originId: "",
          // path: ""
          wx.navigateToMiniProgram({
            appId: itemInfo?.aboutUrl.AppId,
            shortLink: '#小程序://燃气安全/GelhQQ9WOA4jllH',
            path: itemInfo?.aboutUrl.path,
            envVersion: 'develop',
            success(res) {
              // 打开成功
            }
          })
          break
        }
      }
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})